import { getInfo, setInfo } from "@/utils/storage";

export default {
  namespaced: true,
  state() {
    return {
      // 用户信息权证
      // 直接调用 storage 模块的getInfo()
      userInfo: getInfo(),
    };
  },
  mutations: {
    setUserInfo(state, obj) {
      state.userInfo = obj;
      // 存入storage模块
      setInfo(obj);
    },
  },
  actions: {
    // Log out
    loginOut(context) {
      context.commit("setUserInfo", {});
      // Cross component commoit request action an argument {root:true}
      context.commit("cart/setCartList", [], { root: true });
    },
  },
};
